﻿using System;
using System.Collections.Generic;
using System.Linq;
using DLM.Domain.Model;
using DLM.Domain.Repositories;
using DLM.Infrastructure.UnitOfWork;
using DLM.Infrastructure.Domain;
using Webdiyer.WebControls.Mvc;

namespace DLM.Data.EF.CodeFirst.Repositories
{
    public class NoticeRepository : Repository<Notice, int>, INoticeRepository
    {
        public NoticeRepository(IUnitOfWork unitOfWork)
            : base(unitOfWork)
        { }

        public override IEnumerable<Notice> FindAll(int pageIndex, int pageSize)
        {
            return this.ActiveContext.Notice.OrderByDescending(n => n.CreateDate).ToPagedList(pageIndex, pageSize);
        }

        public override IEnumerable<Notice> FindAll(System.Linq.Expressions.Expression<Func<Notice, bool>> query, int index, int count)
        {
            return this.ActiveContext.Notice.Where(query).OrderByDescending(n => n.CreateDate).ToPagedList(index, count);
        }
    }
}
